<?php
/**
 * Модель image
 * 
 * Класс модели
 * @author Anton Zavidov
 * @package myLiveShop
 */

/**
 * Модель image
 *
 */
class ModelImage extends Model {
	
	const TABLE				= 'image';
	const F_IMAGE_ID  	= 'image_id';
	const F_USER_ID  	= 'user_id';
	const F_MODEL_ID  	= 'model_id';
	const F_MODEL  	= 'model';
	const F_FILE  	= 'file';
	const F_FILENAME  	= 'filename';
	const F_CREATED  	= 'created';
	const F_SIZE  	= 'size';
	const F_MIME_TYPE  	= 'mime_type';
	const F_WIDTH  	= 'width';
	const F_HEIGHT  	= 'height';
	const F_SORT  	= 'sort';
			
	public function __construct($className=null){
		parent::__construct(__CLASS__);
		$this->name='image';
		$this->id_field=array(self::F_IMAGE_ID);
		$this->fields=array(
		self::TABLE.DOT.self::F_IMAGE_ID=> new Field($this,self::F_IMAGE_ID,self::TABLE,array(
				'auto'=>true,
				'important'=>true,
				'lenght'=>11)),
		self::TABLE.DOT.self::F_USER_ID=> new Field($this,self::F_USER_ID,self::TABLE,array(
				'lenght'=>11,
				'join_table'=>'user')),
		self::TABLE.DOT.self::F_MODEL_ID=> new Field($this,self::F_MODEL_ID,self::TABLE,array(
				'important'=>true,
				'lenght'=>11)),
		self::TABLE.DOT.self::F_MODEL=> new Field($this,self::F_MODEL,self::TABLE,array(
				'lenght'=>20,
				'type'=>Field::TYPE_STRING)),
		self::TABLE.DOT.self::F_FILE=> new Field($this,self::F_FILE,self::TABLE,array(
				'important'=>true,
				'lenght'=>50,
				'type'=>Field::TYPE_STRING)),
		self::TABLE.DOT.self::F_FILENAME=> new Field($this,self::F_FILENAME,self::TABLE,array(
				'important'=>true,
				'lenght'=>10,
				'type'=>Field::TYPE_STRING)),
		self::TABLE.DOT.self::F_CREATED=> new Field($this,self::F_CREATED,self::TABLE,array(
				'important'=>true,
				'auto'=>true,
				'type'=>Field::TYPE_DATETIME)),
		self::TABLE.DOT.self::F_SIZE=> new Field($this,self::F_SIZE,self::TABLE,array(
				'lenght'=>7)),
		self::TABLE.DOT.self::F_MIME_TYPE=> new Field($this,self::F_MIME_TYPE,self::TABLE,array(
				'lenght'=>20,
				'type'=>Field::TYPE_STRING)),
		self::TABLE.DOT.self::F_WIDTH=> new Field($this,self::F_WIDTH,self::TABLE,array(
				'lenght'=>4)),
		self::TABLE.DOT.self::F_HEIGHT=> new Field($this,self::F_HEIGHT,self::TABLE,array(
				'lenght'=>4)),
		self::TABLE.DOT.self::F_SORT=> new Field($this,self::F_SORT,self::TABLE,array(
				'lenght'=>3))		);
	}
}
